home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / tcomm50.zip / LXM.DOC < prev    next >
Text File  |  1988-01-30  |  36KB  |  1,123 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.                                   INTRODUCING LXM                                  INTRODUCING LXM                                  _______________
  10.  
  11.  
  12.             BRIEF HISTORY OF XMODEM            BRIEF HISTORY OF XMODEM            _______________________
  13.  
  14.  
  15.             During the glory days of CP/M, the computer industry was
  16.             plagued with a plethora of diskette formats. Since there was
  17.             no single standard around, particularly when the 5" format
  18.             was introduced, data interchange between computers was
  19.             difficult.
  20.  
  21.  
  22.             Several manufacturers attempted to provide a solution by
  23.             giving their users the ability to at least read multiple
  24.             diskette formats. Rather than promoting a standard format,
  25.             this approach encouraged manufacturers to adopt proprietary
  26.             formats as a marketing tool. Partially as a response to this
  27.             situation, and partially out of a need to provide data
  28.             transmission capabilities, Ward Christiansen developed the
  29.             original specification for the XModem file transfer
  30.             protocol.
  31.  
  32.  
  33.             The XModem protocol, elegant in its simplicity and
  34.             effectiveness, has transcended the decline of CP/M-based
  35.             systems, and the ascendency of MS-DOS to become a de facto
  36.             standard for data transfer between remote computers. This
  37.             fact is true, even in the light of the near-universal
  38.             acceptance of another de facto standard for diskette
  39.             formats, as popularized by the IBM-PC family. With the
  40.             advent of the new PS/2 with its incompatible micro-
  41.             diskettes, the XModem protocol's place, at least for the
  42.             foreseeable future, seems assured.
  43.  
  44.  
  45.  
  46.                                PROTOCOL FUNDAMENTALS                               PROTOCOL FUNDAMENTALS                               _____________________
  47.  
  48.  
  49.             THE TRANSMISSION BLOCK            THE TRANSMISSION BLOCK            ______________________
  50.  
  51.  
  52.             The fundamental building block of XModem is an 8-bit byte,
  53.             no parity please, arranged into transmission blocks of
  54.             exactly 132 characters, never more nor less. In one
  55.             extension to XModem, commonly called CRC-XModem, the
  56.             transmission blocks are exactly 133 characters. We will
  57.             discuss this extension , and a second known as YModem,
  58.             later.
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  71.                                Datalight and Turbo C
  72.  
  73.             As you might guess, not only is the length of a transmission
  74.             block fixed, but so too is the format. The XModem block
  75.             format looks like this:
  76.  
  77.  
  78.                 <SOH> <REC> <~REC> <...128 Data Bytes...> <checksum>
  79.  
  80.             
  81.  
  82.             where:
  83.             
  84.                  SOH - 0x01 Signals the start of a block
  85.                  REC - Is the sequential block number reduced modulo 256
  86.                  ~REC - The ones-compliment of REC
  87.                  checksum - an 8-bit sum of the preceding 128 data
  88.                       bytes, formed by adding each byte to an
  89.                       accumulator, then dropping all but the low order 8
  90.                       bits of the result.
  91.  
  92.  
  93.             The intent of the additional characters is to facilitate
  94.             error checking and recovery, making the XModem protocol an
  95.             "error-free" means of data transfers under otherwise hostile
  96.             conditions.
  97.  
  98.  
  99.             The block number and its compliment are included to insure
  100.             that no blocks are accidentally lost during transmission,
  101.             and to prevent the accidental duplication of a data block
  102.             which might be caused by spurious line noise. The checksum
  103.             seeks to insure the validity of the actual data which might
  104.             become garbled by line noise. The fixed length block format
  105.             tends to simplify the logic required to implement the
  106.             protocol in the first place.
  107.  
  108.  
  109.  
  110.             THE INTER-COMPUTER DIALOG            THE INTER-COMPUTER DIALOG            _________________________
  111.  
  112.  
  113.             Xmodem is essentially uni-directional in nature. That is,
  114.             the actual flow of meaningful information occurs in one
  115.             direction at a time, from the sending computer to the
  116.             receiving computer. This is not meant to imply, however,
  117.             that only one computer sends and the computer receives. To
  118.             the contrary, there is a constant "dialog" going on between
  119.             the two computers during the course of the transmission. It
  120.             is this dialog that permits XModem to be true, "error-free"
  121.             transfer method.
  122.  
  123.  
  124.  
  125.  
  126.  
  127.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  137.                                Datalight and Turbo C
  138.  
  139.             Xmodem is a receiver-driven protocol. The receiving computer
  140.             initiates and almost exclusively controls the transmissions,
  141.             through a series of pre-planned responses. A typical, though
  142.             brief dialog might look like this:
  143.  
  144.  
  145.                  RECEIVER            SENDER            MEANING                 ________            ______            _______
  146.             
  147.                   <NAK>         -------------->    READY TO RECEIVE
  148.               <-------------        <BLOCK1>       FIRST BLOCK SENT
  149.                   <ACK>         -------------->   BLOCK RECEIVED OK
  150.               <-------------        <BLOCK2>         SECOND BLOCK
  151.                   <NAK>         -------------->     ERROR, RESEND
  152.               <-------------        <BLOCK2>         SECOND BLOCK
  153.                   <ACK>         -------------->   BLOCK RECEIVED OK
  154.               <-------------         <EOT>           END OF FILE
  155.                   <ACK>         -------------->    E-O-F UNDERSTOOD
  156.  
  157.  
  158.             As you can see, it is through the responses to the sending
  159.             computer that the receiver controls the link.
  160.  
  161.  
  162.             Xmodem also makes provision for unusual circumstances by
  163.             providing both time-out and cancellation mechanisms. The
  164.             rules for time-outs, time periods which may elapse before a
  165.             disruption in transmission occurs are as follows:
  166.  
  167.  
  168.  
  169.                 1. Waiting for SOH - 10 seconds, Resend last
  170.                    acknowledgement on time-out.
  171.  
  172.  
  173.                 2. Waiting for other block characters - 1 second,
  174.                    replace expected character with some pre-defined
  175.                    value upon time-out.
  176.  
  177.  
  178.                 3. Waiting for a reply to a block - 10 seconds,
  179.                    Resend last block upon time-out.
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  203.                                Datalight and Turbo C
  204.  
  205.             The original protocol description also makes it possible for
  206.             either the sender or receiver to cancel the transmission.
  207.             This is of particular value when too many transmission
  208.             errors occur, or, in rare cases, when the physical
  209.             connection is broken. The threshold beyond which either side
  210.             may request cancellation, although specified as 10 attempts
  211.             in the original description of the protocol, has become
  212.             somewhat arbitrary over time. The cancellation code, <CAN>
  213.             or 0x10, may be sent by either the sender or receiver in
  214.             place of the <SOH> or normal acknowledgment character
  215.             respectively.
  216.  
  217.  
  218.  
  219.             ENHANCEMENTS TO XMODEM            ENHANCEMENTS TO XMODEM            ______________________
  220.  
  221.  
  222.             Over the years, several significant enhancements have been
  223.             made to the protocol as originally defined by Ward
  224.             Christiansen. The intent of these enhancements have
  225.             generally been to improve upon the error-handling capability
  226.             of the protocol, and to make the protocol more amenable to
  227.             some less time-efficient communications environments,
  228.             particularly those presented by for-pay services such as
  229.             CompuServe.
  230.  
  231.  
  232.             To make the protocol more error-free, the checksum employed
  233.             in the original design has been replaced by a 16 bit
  234.             calculation, called a Cyclical Redundancy Check or CRC.
  235.             Based upon a polynomial equation, the CRC method can be
  236.             mathematically demonstrated to be sensitive to all but about
  237.             .03 per cent of errors. This error detection rate, about
  238.             99.97 percent accurate, is far superior to the approximately
  239.             90 to 92 percent accuracy of the checksum approach. The
  240.             overhead of an additional 8 bits per message seems to make
  241.             this enhancement well worth while.
  242.  
  243.  
  244.             The second enhancement seeks to improve communication over
  245.             packet-switched networks, like those employed by CompuServe
  246.             and other national services. Basically this enhancement
  247.             introduces a relaxed time-out between characters in a block,
  248.             allowing additional time before the protocol recognizes a
  249.             time-out condition.
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  269.                                Datalight and Turbo C
  270.  
  271.             A third enhancement, variant of the original XModem protocol
  272.             seeks to improve overall efficiency by expanding the block
  273.             size from 128 characters to 1024 characters.  This variant,
  274.             commonly call ymodem, reduces the number of times that an
  275.             acknowledgment sequence must be sent, thereby increasing the
  276.             efficiency of actual data transfer.
  277.  
  278.  
  279.             The LXM XModem engine supports all of the enhancements
  280.             mentioned above.
  281.  
  282.  
  283.  
  284.                                    THE LXM ENGINE                                   THE LXM ENGINE                                   ______________
  285.  
  286.  
  287.             OVERVIEW            OVERVIEW            ________
  288.  
  289.  
  290.             One of the reasons for the popularity of the XModem protocol
  291.             over time is the simplicity of the implementation. Given a
  292.             reasonable communications package upon which to build,
  293.             developing a basic implementation of XModem is relatively
  294.             simple, although under certain operating systems, such as
  295.             the Unix family, the attempt of the OS to be all things to
  296.             all people may actually become an impediment.
  297.  
  298.  
  299.             The intent of the LXM engine is to 1) provide XModem
  300.             capability, 2) in a flexible, easy to understand package, 3)
  301.             built upon a sound foundation, the LiteComm communications
  302.             ToolBox. Because of the manner in which the LXM engine was
  303.             designed virtually any application can have access to
  304.             XModem's error-free protocol, without being relegated to
  305.             simply transferring files.
  306.  
  307.  
  308.  
  309.             MAJOR ENGINE COMPONENTS            MAJOR ENGINE COMPONENTS            _______________________
  310.  
  311.  
  312.             The LXM engine consists, primarily of two functions, lcxrrec
  313.             and lcxtrec, receive a record and transmit a record
  314.             respectively. Because these two functions 'understand' the
  315.             XModem protocol internally, they assume full responsibility
  316.             for all of the necessary housekeeping, relying upon the host
  317.             program for only the most basic of functions.
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  335.                                Datalight and Turbo C
  336.  
  337.             The lcxrrec function receives one or more records from a
  338.             companion system. The host program controls the checking
  339.             method, CRC or checksum, the time-out method, normal or
  340.             relaxed, handles, in what ever way appropriate, blocks of
  341.             data that have been received, and can optionally monitor the
  342.             flow of data from the companion system. Lcxrrec assumes the
  343.             responsibility for synchronizing with the companion system
  344.             and for correctly maintaining the flow of information.
  345.  
  346.  
  347.             Lcxtrec performs in a like fashion when the host program
  348.             wants to send one or more records. The host program has only
  349.             to present the record to be transmitted, and lcxtrec does
  350.             the rest. The lcxtrec module assumes responsibility for
  351.             establishing synchronization with the receiving computer,
  352.             and for recognizing the checking method, CRC or checksum,
  353.             that the receiver wants to use. Lcxtrec also terminates the
  354.             transmission, when told to do so by the host program, and
  355.             permits the host to optionally monitor the data flow.
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  401.                                Datalight and Turbo C
  402.  
  403.                                  NOTES AND WARNINGS                                 NOTES AND WARNINGS                                 __________________
  404.  
  405.  
  406.             MODIFICATIONS            MODIFICATIONS            _____________
  407.  
  408.  
  409.             The LXM engine is closely integrated with the LiteComm
  410.             ToolBox. While there is every likelihood that the engine can
  411.             be modified to function with other similar packages,
  412.             Information Technology, Ltd., can only support the LXM
  413.             engine when used with either the LiteComm ToolBox.
  414.  
  415.  
  416.  
  417.             PARITY AND DATA BITS            PARITY AND DATA BITS            ____________________
  418.  
  419.  
  420.             The XModem protocol is an 8-bit protocol. That is to say it
  421.             neither recognizes nor tolerates parity checking, i.e. 7
  422.             data bits plus a specified parity. Since the LXM engine
  423.             cannot determine the current settings for parity and number
  424.             of data bits, the responsibility for controlling these
  425.             settings rests with the host program. Before using either of
  426.             the key functions lcxrrec or lcxtrec, the host program must
  427.             insure that the settings are no parity, 8 data bits, using
  428.             the comm_setup function. Upon final termination of the
  429.             function, the host program must reset these values to their
  430.             original settings, if necessary.
  431.  
  432.  
  433.  
  434.             INTERNAL TIMER FUNCTION            INTERNAL TIMER FUNCTION            _______________________
  435.  
  436.  
  437.             Both lcxrrec and lcxtrec employ a hardware-based timing
  438.             function that connects directly to the normal real-time
  439.             clock vector 0x1C; The Microsoft and Turbo C version of this
  440.             function also establishes an special routine, using the
  441.             atexit() function, to insure that this vector is re-
  442.             established at is original setting when program termination
  443.             occurs. This is not true of the Datalight version however.
  444.             The Datalight library does not, at present, have an like
  445.             atexit().
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  467.                                Datalight and Turbo C
  468.  
  469.             While every effort has been made, for Datalight users, to
  470.             insure that the vector is properly reset, this plan may be
  471.             thwarted by abnormal termination of the host program
  472.             resulting in a subsequent system crash. The safest method to
  473.             Datalight user's to employ would be to use the lc_clrclock()
  474.             function before host program termination. As an alternate
  475.             approach, Datalight users may want to investigate STEVE'S
  476.             LIBRARY designed for Datalight C users's. This excellent
  477.             library does have an equivalent function to the atexit().
  478.  
  479.  
  480.  
  481.             BUFFER SIZE RESTRICTION            BUFFER SIZE RESTRICTION            _______________________
  482.  
  483.  
  484.             The LiteComm ToolBox permits you a great deal of freedom in
  485.             tailoring the communications handler to meet your specific
  486.             requirements. We must caution you, however, that when you
  487.             are using the LXM engine, the minimum buffer sizes required
  488.             by the comm_opn function are not adequate to support LXM,
  489.             particularly when transmitting records at either low baud
  490.             rates, or on the new generation of high-speed (above 6 MHz)
  491.             processors.
  492.  
  493.  
  494.             During the development of LXM, it was quickly discovered
  495.             that too small a transmit buffer quickly resulted in a
  496.             buffer overflow condition. We recommend that, when using the
  497.             LXM engine, the transmit buffer be set at a minimum 256
  498.             bytes to avoid the overflow condition.  If you intended to
  499.             employ the YModem variant, then the minimum buffer sizes
  500.             should be set to at least 1030.
  501.  
  502.  
  503.  
  504.             XON-XOFF CONTROL            XON-XOFF CONTROL            ________________
  505.  
  506.  
  507.             If your host program employs the XON-XOFF functions in
  508.             LiteComm, you must be sure that the automatic XON-XOFF
  509.             handing is disabled before you attempt to transmit or
  510.             receive records using LXM. Failure to observe this caution
  511.             may result in a system hang, requiring that the system be
  512.             re-booted.
  513.  
  514.  
  515.  
  516.             USER-ACCESSIBLE DATA            USER-ACCESSIBLE DATA            ____________________
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  533.                                Datalight and Turbo C
  534.  
  535.             Within LXM, certain variables have been defined as being
  536.             globally available. The host program may examine the
  537.             contents of these variables at any time to determine the
  538.             current state of the LXM engine. The correct definitions of
  539.             these variable is contained in litexm.h. Except as noted
  540.             below, the host program must NOT alter the contents of these
  541.             variables.
  542.  
  543.  
  544.  
  545.                 abort_flag - This is the only variable of the group                __________                                         
  546.                    that may be altered by the host program. The
  547.                    flag is checked periodically by the engine
  548.                    functions. If _abort_flag has a value of 1, the
  549.                    function in progress will be cancelled
  550.                    automatically by sending a CAN instruction to
  551.                    the companion system. See the TTL.C sample
  552.                    program for an example of how this flag may be
  553.                    set.
  554.  
  555.  
  556.                 crc   - If this variable has a non-zero value, then                ___                                                
  557.                    the LXM engine is currently using the CRC error-
  558.                    checking method. A zero value indicates that the
  559.                    original checksum method is being used.
  560.  
  561.  
  562.                 checksum and crcaccum-These variables hold the                _____________________                         
  563.                    current/last calculated check value. In a
  564.                    practical sense, they are of no value to the
  565.                    host program.
  566.  
  567.  
  568.                 rec   - This variable contains the current record                ___                                              
  569.                    (block) number being processed. In the event of
  570.                    an uncorrectable error, rec would contain the
  571.                    number of the expected block. In the case of a
  572.                    successful transmission or reception, rec-1 is
  573.                    the number of the block sent or received. The
  574.                    value contained in this variable, reduced modulo
  575.                    256, provides the block number required by the
  576.                    XModem protocol and must NEVER be disturbed.
  577.  
  578.  
  579.                 ymodem     - This variable is set to TRUE if the                ______                                          
  580.                    host application wants to transmit a block in
  581.                    YModem mode (1024 characters). See the
  582.                    discussion of lcxtrec, below.
  583.  
  584.  
  585.                                PROGRAMMERS REFERENCE                               PROGRAMMERS REFERENCE                               _____________________
  586.  
  587.  
  588.  
  589.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  599.                                Datalight and Turbo C
  600.  
  601.             ENGINE-RELATED FUNCTIONS            ENGINE-RELATED FUNCTIONS            ________________________
  602.  
  603.  
  604.             The following pages document the LXM engine functions as
  605.             currently implemented.  They follow, in style and content,
  606.             the documentation for the LiteComm ToolBox itself.
  607.  
  608.  
  609.             Use the following pages as an addendum to your LiteComm
  610.             documentation.
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  665.                                Datalight and Turbo C
  666.            _______________________________________________________________
  667.  
  668.                                       lcxrrec
  669.            _______________________________________________________________
  670.  
  671.  
  672.             SUMMARY            SUMMARY            _______
  673.  
  674.                  #include <litexm.h>
  675.                  #include <litecomm.h>
  676.                  
  677.                  int lcxrrec(port,buff,rbsize,hmode,hdshk)
  678.                       unsigned port;
  679.                       unsigned char *buff;
  680.                       int *rbsize;
  681.                       int hmode;
  682.                       unsigned char *hdshk;
  683.  
  684.  
  685.             DESCRIPTION            DESCRIPTION            ___________
  686.  
  687.             Receive a block of either 128 or 1024 bytes from the
  688.             companion system, using the checking method specified in
  689.             hdshk, and the time-out value specified in hmode.  If
  690.             necessary, establish synchronization with the companion
  691.             system.
  692.  
  693.  
  694.             The port parameter is the same as used throughout the
  695.             LiteComm ToolBox.
  696.  
  697.  
  698.             Buff should be a pointer to an array of 128 bytes in when
  699.             using XModem mode, 1024 bytes for YModem mode.  All record
  700.             characters are received into this area, and, if the area is
  701.             too small, LXM will overwrite adjacent data without warning.
  702.  
  703.  
  704.             Rbsize is a POINTER to an integer variable.  Lcxrrec returns
  705.             the actual length of the received block to this variable.
  706.             This approach is needed since, using YModem, blocks may be
  707.             either 1024 bytes or 128 bytes at the discretion of the
  708.             SENDER.  Lcxrrec automatically detects the block length and
  709.             returns it to the caller so that the caller can process the
  710.             block correctly.
  711.  
  712.  
  713.             The value of hmode determines whether normal or relaxed
  714.             time-out values are used. Please use the constants provided
  715.             in the litexm header file to insure a proper setting.
  716.  
  717.             The value contained initially in hdshk must be either CRC or
  718.             NAK, defined in litexm.h. The former specifies the use of
  719.  
  720.  
  721.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  731.                                Datalight and Turbo C
  732.  
  733.             the 16 bit CRC checking mode, while the latter specifies the
  734.             use of the original checksum method.  Note - If you intend
  735.             to operate in YModem mode, hdshk must specify CRC.
  736.  
  737.             Note that hdshk is a pointer to a character. Lcxrrec uses
  738.             this area to store its reply to the last received block.
  739.             Once you have set this value, and have started to receive,
  740.             DO NOT alter its value under any circumstances. Doing so may
  741.             cause unpredictable results.
  742.  
  743.  
  744.  
  745.             EXAMPLE            EXAMPLE            _______
  746.  
  747.             See the accompanying program TTL for an example of lcxrrec
  748.             usage.
  749.  
  750.  
  751.  
  752.             RETURN VALUES            RETURN VALUES            _____________
  753.  
  754.             Lcxrrec may return several values, as defined in the
  755.             litexm.h file. Each return value should cause the host
  756.             program to respond in specific ways.
  757.  
  758.  
  759.             SUCCESS - A record has been successfully received into the            SUCCESS                                                   
  760.             buff area. Host program process the record and calls lcxrrec
  761.             again.
  762.  
  763.  
  764.             RETRIES - The maximum number of attempts to receive a single            RETRIES                                                     
  765.             record has been exceeded. Lcxrrec automatically cancels the
  766.             session. Host program should handle in an appropriate
  767.             manner, e.g. issue error message.
  768.  
  769.  
  770.             ERR (-1) - Lcxrrec has detected that the host program has            ERR                                                      
  771.             requested cancellation of transmissions through the
  772.             _abort_flag setting (see below) or a fatal record sequence
  773.             has occurred, e.g. a block number has been skipped. Lcxrrec
  774.             automatically cancels the session.
  775.  
  776.  
  777.             CAN - The sending program has requested cancellation. Host            CAN                                                       
  778.             program should handle in a fashion similar to RETRIES.
  779.  
  780.  
  781.             EOT - The sending program has no more data to transmit.            EOT                                                    
  782.             Lcxrrec acknowledges the EOT message automatically. Host
  783.             program handles like an end-of-file condition.
  784.  
  785.  
  786.  
  787.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  797.                                Datalight and Turbo C
  798.  
  799.             TOUT - Lcxrrec failed to establish synchronization with the            TOUT                                                       
  800.             sending program while waiting to receive the SOH (or STX for
  801.             YModem) character at the start of the block. The session is
  802.             automatically cancelled.
  803.  
  804.  
  805.             DUPSEQ - The block just received is a duplicate of the            DUPSEQ                                                
  806.             preceding block. The host program should ignore the data
  807.             contained within the block, the call lcxrrec to proceed with
  808.             data transfer.
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  863.                                Datalight and Turbo C
  864.            _______________________________________________________________
  865.  
  866.                                       lcxtrec
  867.            _______________________________________________________________
  868.  
  869.  
  870.             SUMMARY            SUMMARY            _______
  871.  
  872.                  #include <litexm.h>
  873.                  #include <litecomm.h>
  874.                  
  875.                  int lcxtrec(port, buff)
  876.                  
  877.                       unsigned port;
  878.                       unsigned char *buff;
  879.  
  880.  
  881.             DESCRIPTION            DESCRIPTION            ___________
  882.  
  883.             Transmit a block of 128 or 1024 bytes to the companion
  884.             system. The checking protocol, CRC or checksum, is detected
  885.             automatically when the receiving station issues its initial
  886.             handshaking sequence. If necessary, establish
  887.             synchronization with the companion system before
  888.             transmitting.
  889.  
  890.  
  891.             The port parameter is the same as used throughout the
  892.             LiteComm ToolBox.
  893.  
  894.  
  895.             Buff should be a pointer to a 128 or 1024 byte record to be
  896.             sent to the companion system. This is not a typical, null-
  897.             terminated string as usually found in C. All bytes, starting
  898.             at the pointer will be transmitted. It is the responsibility
  899.             of the host program to provide any padding that might be
  900.             required to satisfy the length requirement.  Generally,
  901.             short records are padded with NULLS or ^Z (0x1A).
  902.  
  903.  
  904.             Lcxtrec determines the block size to be transmitted based
  905.             upon the current value of the global variable ymodem (see
  906.             the introduction). If ymodem has a value of TRUE, then buff
  907.             is assumed to point to a 1024 byte record.  If ymodem is
  908.             FALSE, then a 128 byte record is assumed.  This feature has
  909.             particular value when operating in YModem mode.
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  929.                                Datalight and Turbo C
  930.  
  931.             When using YModem protocol, block sizes may be either 128 or
  932.             1024 bytes, at the senders discretion.  This serves two
  933.             purposes.  In the case of a large number of errors, many
  934.             YModem implementations will automatically switch to the
  935.             smaller block size if too many errors occur using the larger
  936.             block size, in an effort to get the data through, then
  937.             revert back to the normal block of 1024 characters.  Lcxtrec
  938.             implements this feature automatically.
  939.  
  940.  
  941.             Generally, at the end of a file, the final block to be sent
  942.             will not exactly match the transmission block size. Under
  943.             XModem, this means that as many as 127 wasted characters
  944.             might be transmitted.  Under YModem, as many as 1023 wasted
  945.             characters can be transmitted in the final block.  However,
  946.             the host program that calls lcxtrec can determine if the
  947.             block to be sent is less than 1024 bytes, set the ymodem
  948.             variable to FALSE, and send multiple 128 byte blocks.  Using
  949.             this approach, the amount of wasted characters will be no
  950.             worse than the original XModem.  The TTL sample program,
  951.             included in the package, shows one way of approaching this
  952.             problem.
  953.  
  954.  
  955.  
  956.             EXAMPLE            EXAMPLE            _______
  957.  
  958.             See the accompanying program TTL for an example of lcxtrec
  959.             usage.
  960.  
  961.  
  962.  
  963.             RETURN VALUES            RETURN VALUES            _____________
  964.  
  965.             Lcxtrec may return several values, as defined in the
  966.             litexm.h file. Each return value should cause the host
  967.             program to respond in specific ways.
  968.  
  969.  
  970.             SUCCESS - The record has been successfully sent from the            SUCCESS                                                 
  971.             buff area. Host program either calls lcxtrec with the next
  972.             record to transmit, or lcxteot to indicate End of
  973.             Transmission to the companion system.
  974.  
  975.  
  976.             RETRIES - The maximum number of attempts to send a single            RETRIES                                                  
  977.             record has been exceeded. Lcxtrec automatically cancels the
  978.             session. Host program should handle in an appropriate
  979.             manner, e.g. issue an error message.
  980.  
  981.  
  982.  
  983.  
  984.  
  985.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  995.                                Datalight and Turbo C
  996.  
  997.             ERR (-1) - Lcxtrec has detected that the host program has            ERR                                                      
  998.             requested cancellation of transmissions  through the
  999.             _abort_flag setting (see below).
  1000.  
  1001.  
  1002.             CAN - The receiving program has requested cancellation.            CAN                                                    
  1003.             Host program should handle in a fashion similar to RETRIES.
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.                 LXM(tm) - LITECOMM (tm) XMODEM ENGINE for Microsoft
  1061.                                Datalight and Turbo C
  1062.            _______________________________________________________________
  1063.  
  1064.                                       lcxteot
  1065.            _______________________________________________________________
  1066.  
  1067.  
  1068.             SUMMARY            SUMMARY            _______
  1069.  
  1070.                  #include <litexm.h>
  1071.                  #include <litecomm.h>
  1072.                  
  1073.                  int lcxtrec(port)
  1074.                  
  1075.                       unsigned port;
  1076.  
  1077.  
  1078.             DESCRIPTION            DESCRIPTION            ___________
  1079.  
  1080.             Send and End of Transmission (End of File) to the receiving
  1081.             system. This function must be called to successfully close
  1082.             out the transmission session.
  1083.  
  1084.  
  1085.  
  1086.             EXAMPLE            EXAMPLE            _______
  1087.  
  1088.             See the accompanying program TTL for an example of lcxtrec
  1089.             usage.
  1090.  
  1091.  
  1092.  
  1093.             RETURN VALUES            RETURN VALUES            _____________
  1094.  
  1095.             Lcxteot returns one of two values, as defined in the
  1096.             litexm.h file.
  1097.  
  1098.             SUCCESS - The receiving station has correctly acknowledged            SUCCESS                                                   
  1099.             the EOT. The host program terminates transmission mode
  1100.             normally.
  1101.  
  1102.             CAN - Either the receiving system has responded to the EOT            CAN                                                       
  1103.             message with a CAN code, or has failed to respond correctly
  1104.             and the lcxteot function has sent the CAN code to the
  1105.             receiving system. Host program should handle in an
  1106.             appropriate manner, e.g. issue an appropriate error message.
  1107.  
  1108.  
  1109.             Regardless of the value returned, invoking lcxteot always
  1110.             terminates the current transmission session.
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.                CopyRight (c) 1987, 1988 Information Technology, Ltd.
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.